<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"/>
    <title>实名认证</title>
    <link rel="stylesheet" href="../css/base.css"/>
    <link rel="stylesheet" href="../css/publish.css"/>
    <style>
        .seting em{
            left: 3%;
        }
        .info{
            padding:0.5rem;
            padding-top: 2.5rem;
            background: #eee;
            font-size: 0.28rem;
            color:#b2b2b2;
            text-align: center;
        }
            .center{
                width: 100%;

            }
        .center div{
            color:#999999;
            font-size: 0.3rem;
           padding-left: 0.3rem ;
            height: 1rem;
            position: relative;
            border-bottom: 1px solid #eee ;
        }
        .center input{
            display: inline-block;
            height: 0.9rem;
            line-height: 1rem;
            padding-left: 0.1rem;
            color:#999;
            width: 81%;

        }
        .e_code span{
            position: absolute;
            right: 5%;
            top: 12%;
            font-size: 0.24rem;
            padding:0.15rem 0.4rem;
            background-color:#eee;
            border-radius:20px;
        }
        .start{
            width: 90%;
            left: 5%;
            height: 1rem;
            line-height: 1rem;
            background-color: #71462a;
            position: relative;
            color:#fff;
            text-align: center;
            font-size: 0.3rem;
            border-radius: 5px;
            margin-top: 0.5rem;
        }
    </style>
</head>
<body>
<div class="layer">
    <header class="seting">
        <em onclick="back()"></em>
        <h3>实名认证</h3>
    </header>
    <p class="info">请填写个人真实信息，否则无法通过认证</p>
<div class="center">
    <div>真实姓名 <input type="text" class="realName"/></div>
    <div>身份证号 <input type="text" class="IDcard"/></div>
   <!-- <div>手机号 <input type="text" class="phone" id="phone"/></div>
    <div class="e_code">验证码 <input type="text" class="code"/> <span> 获取验证码</span></div>-->
</div>
    <div class="start">开始认证</div>
</div>
<script src="../js/x_rem.js"></script>
<script src="../js/base.js"></script>
<script src="../js/jquery.js"></script>
<script>
    $(function () {
        $(".realName").blur(function(){
            realName($(".realName").val());
        })
        $(".IDcard").blur(function(){
            isCardNo($(".IDcard").val());
        })
        //验证姓名
        function realName(name) {
            var regName =/^[\u4e00-\u9fa5]{2,4}$/;
            if(regName.test(name)==false) {
               // alert('真实姓名填写有误');
                $("input").val("");
                return false;
            }
        }
        //验证 身份证号
        function isCardNo(card)
        {
            // 身份证号码为15位或者18位，15位时全为数字，18位前17位为数字，最后一位是校验位，可能为数字或字符X
            var reg = /(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
            if(reg.test(card) === false)
            {
                alert("身份证输入不合法");
                $(".IDcard").val("");
                return  false;
            }
        }
        $(".start").click(function() {
            //获取真实姓名 身份证号
            var realName = $(".realName").val();
            var idCard = $(".IDcard").val();
            $.ajax({
                //处理session每次不唯一问题
                xhrFields: {
                    withCredentials: true
                },
                //请求方式
                type: 'POST',
                url: 'http://192.168.1.126/student/updateStudentRealMessage',
                dataType: 'json',
                data: {
                    realName: realName,
                    idCard: idCard
                },
                success: function (data) {
                    console.log(data);
                    if(data.code=="success"){
                        $(".start").text("已提交，正在审核");
                     location.href="./seting.html";
                    }
                },

            })
        })
       /* //获取短信验证码
        function getcode(){
            if(!flag){
                return;
            }
            var mobile = $('#phone').val();
            if(!checkTelNum(mobile)){
                alert('手机号码不正确');
                $('#phone').val("");
                return false;
            }
            // var uuid=Math.random().toString(36).substr(2);
            //var obj = {mobile:mobile,uuid:uuid,type:1};
            flag = false;
            $.ajax({
                xhrFields: {
                    withCredentials: true
                },
                type: "post",
                url: "http://192.168.1.126/student/doCode",
                data: {
                    mobilePhone:mobile
                },
                datType: 'json',
                success: function (data){
                    //alert(data);
                    console.log(data);
                    console.log(data.code);

                    window.localStorage.setItem("code",JSON.stringify(data.code));
                }
            })
        }
        //验证手机号
        function checkTelNum(telNum){
            if(!/^1[0-9]{10}$/.test(telNum)){
                return false;
            }
            return true;
        }*/

    })
</script>
</body>
</html>